<template>
	<view class="shopping-details-address">
		<u-popup :show="show" mode="bottom" :overlay="true" round="30rpx" @open="open">
			<view class="box">
				<view class="" style="height: 32rpx;"></view>
				<view class="header">
					<view class="title">{{title}}</view>
					<view class="icon-close" @click="close">
						<u-icon name="close" size="12" color="#BDBDBD"></u-icon>
					</view>
				</view>
				<view class="" style="height: 40rpx;"></view>
				<view class="list">
					<view class="list-item" v-for="(item,index) in listData" :key="index" @click="listDataIndex = index">
						<view class="label">{{item}}</view>
						<view class="value" :class="index==listDataIndex?'active':''"></view>
					</view>
				</view>
				<view class="btn" @click="handleAdd">确定</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		addressList
	} from "@/http";
	export default {
		props:{
			title:{
				type:String,
				default:()=> ""
			}
		},
		data() {
			return {
				show: false,
				val: false,
				userInfo: uni.getStorageSync('userInfo'),
				listData: ['7天无理由','商品与页面描述不符','价格变化','少件/发错货/未收到货','商品质量/故障','商品破损/包装问题'],
				listDataIndex: 0,
				options:{}
			}
		},

		methods: {
			async init(options) {
				try {
					this.options = options;
					this.show = true;
				} catch (e) {
					console.error('error',e)
					uni.hideLoading();
					//TODO handle the exception
				}
			},
			handleAdd() {
				this.$emit("submit",{
					...this.options,
					refuseReason: this.listData[this.listDataIndex]
				});
				this.show = false;
			},
			open() {
				// console.log('open');
			},
			close() {
				this.show = false;
				// console.log('close');
			}
		}
	}
</script>

<style lang="scss" scoped>
	.shopping-details-address {
	.list{
		.list-item{
			display: flex;
			justify-content: space-between;
			margin-bottom: 56rpx;
			padding: 0 32rpx;
			font-size: 30rpx;
			color: #1F1F1F;
			.value{
				position: relative;
				border-radius: 50%;
				width: 38rpx;
				height: 38rpx;
				border: 4rpx solid #FD8F19;
			}
			.value.active::after{
					content: "";
					position: absolute;
					left: 50%;
					top: 50%;
					margin-top: -12rpx;
					margin-left: -12rpx;
					height:24rpx;
					width: 24rpx;
					border-radius: 50%;
					background-color: #FD8F19;
				}
		}
	}
		.box {
			.btn {
				margin: 0 auto;
				margin-top: 10rpx;
				margin-bottom: calc(env(safe-area-inset-bottom) + 78rpx);
				width: 686rpx;
				height: 80rpx;
				line-height: 80rpx;
				text-align: center;
				background: #FD8F19;
				border-radius: 40rpx;
				font-size: 32rpx;
				font-weight: 400;
				color: #FFFFFF;
			}


			.header {
				position: relative;

				.title {
					width: 100%;
					text-align: center;
					font-size: 30rpx;
					font-weight: 500;
					color: #1F1F1F;
				}

				.icon-close {
					position: absolute;
					right: 32rpx;
					top: 50%;
					transform: translate(0, -50%);
					background-color: #F1F1F1;
					height: 38rpx;
					width: 38rpx;
					border-radius: 50%;
					display: flex;
					align-items: center;
					justify-content: center;
				}
			}
		}
	}
</style>
